{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="ibox float-e-margins">
        <div class="ibox-content">
            <div class="row">
                <!--搜索框开始-->
                <div class="col-sm-12">
                    <div class="layui-form layui-form-item">

                        <div class="layui-col-md6 layui-input-inline" style="margin-top: 5px">
                            <input type="text" id="keyword" class="layui-input search" name="keyword" value="" placeholder="ID|姓名|登录手机号|身份证"/>
                        </div>
                        <div class="layui-col-md6 layui-input-inline"  style="margin-top: 5px">
                            <select name="user_status" class="layui-input search">
                                <option value="">不限状态</option>
                                <option value="1">正常</option>
                                <option value="2">冻结</option>
                            </select>
                        </div>
                        <div class="layui-col-md6 layui-input-inline" style="margin-top: 5px">
                            <input type="text" id="start" class="layui-input search" name="start" value="" placeholder="入学年份开始"/>
                        </div>

                        <div class="layui-col-md6 layui-input-inline" style="margin-top: 5px">
                            <input type="text" id="end" class="layui-input search" name="end" value="" placeholder="入学年份结束"/>
                        </div>
                        <div class="layui-col-md6 layui-input-inline" id="forschool"  style="margin-top: 5px">
                            <select name="user_school" class="layui-input search" xm-select="select2" xm-select-radio="" xm-select-search="" xm-select-search-type="dl">
                                <option value=" ">全部学校</option>
                                {foreach name="school" item="v"}
                                <option value="{$v.school_id}">{$v.school_name}</option>
                                {/foreach}
                            </select>
                        </div>
                        <div class="layui-input-inline" style="margin-top: 5px">
                            <button class="layui-btn" lay-submit="" lay-filter="LAY-search">立即搜索</button>
                            <button  class="layui-btn layui-btn-normal" id="empty"  lay-submit="" lay-filter="LAY-search">重置</button>
                        </div>
                    </div>
                </div>

                <div class="col-sm-12">
                    <div class="input-group" >
                        <button  class="btn btn-danger m-l-xs" href="javascript:;" data-toggle="dropdown">
                            <i class="fa fa-wrench"></i> 导出 <span class="caret"></span>
                        </button>
                        <ul class="dropdown-menu layui-anim layui-anim-upbit" role="menu">
                            <li><a  href="javascript:;" class="layuiBtn" data-type="excelAll"><i class="fa fa-print"></i> 导出用户</a></li>
                        </ul>
                    </div>
                </div>
            </div>
            <div class="hr-line-dashed"></div>

            <div class="example-wrap">
                <div class="example">
                    <table class="layui-hide" id="test" lay-filter="demo"></table>
                    <!--操作模板-->
                    <script type="text/html" id="user_status">
                    {{# if(d.user_status == 1){ }}
                    正常
                    {{# } }}
                    {{# if(d.user_status == 2){ }}
                    已冻结
                    {{# } }}
                    </script>
                    <script type="text/html" id="sex">
                    {{# if(d.user_gender == 1){ }}
                    男
                    {{# } }}
                    {{# if(d.user_gender == 2){ }}
                    女
                    {{# } }}
                    </script>
                    <script type="text/html" id="opeBar">
                        {{# if(!d.uson_status || d.uson_status == 1){ }}
                            <a href="javascript:;" onclick="wk.layer_show('编辑', '{:url('memberedit')}?user_id={{d.user_id}}&uson_id={{d.uson_id}}')" class="btn btn-primary btn-xs m-r-xs" title="编辑">编辑</a>
                        {{# } }}
                        <!-- 把冻结和启用拎出来了-->
                        {{# if(d.user_status == 1){ }}
                        <a href="javascript:;" onclick="wk.confirm('{{d.user_id}}','{:url('down')}','确定冻结吗?')" class="btn btn-danger btn-xs m-r-xs" title="冻结">冻结</a>
                        {{# } }}
                        {{# if(d.user_status == 2){ }}
                        <a href="javascript:;" onclick="wk.confirm('{{d.user_id}}','{:url('up')}','确定启用吗?')" class="btn btn-warning btn-xs m-r-xs" title="启用">启用</a>
                        {{# } }}
                        <!--   end   把冻结和启用拎出来了-->
                        {{# if(d.uson_status && d.uson_status != 1){ }}
                        <a href="javascript:;" style="color: red">已删</a>
                        {{# } }}
                        <a href="javascript:;" onclick="wk.layer_show('详情', '{:url('memberDetail')}?user_id={{d.user_id}}&uson_id={{d.uson_id}}')" class="btn btn-primary btn-xs m-r-xs" title="详情">详情</a>
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script>
    //layui渲染数据表格
    layui.use('table', function () {
        var table = layui.table
                , form = layui.form;
        table.render({
            elem: '#test'
            , url: '{:url("Member/index")}'
            ,response: {
                statusCode: 220 //成功的状态码，默认：0
            }
            , page: true
//            , size: 'lg' //sm小尺寸的表格 lg大尺寸
            , cellMinWidth: 150
            , limits: [5, 10, 15, 20, 25, 300]
            , limit: "{:config('pages')}"
            , loading: true
            , id: 'testReload'
            , cols: [[
//                {type: 'checkbox', fixed: 'left'}
                  {type:'numbers', width: 60, title: '序号'}
                , {field: 'user_id', width: 60, title: 'ID', align: 'center'}
                , {field: 'user_username', width: 130, title: '昵称', align: 'center'}
                , {field: 'user_phone', width: 120, title: '手机号码', align: 'center'}
                , {field: 'uson_username', width: 120, title: '学生姓名', align: 'center'}
                , {field: 'school_name', width: '', title: '学校', align: 'center'}
                , {field: 'uson_idcard', width: '', title: '身份证', align: 'center'}
                , {field: 'user_gender', width: '', title: '性别', align: 'center',toolbar: '#sex'}
                , {field: 'uson_year', width: '', title: '入学年份', align: 'center'}
                , {field: 'uson_grade', width: '', title: '年级', align: 'center'}
                , {field: 'wx', width: 90, title: '微信登录', align: 'center'}
                , {field: 'user_time', width: 160, title: '注册时间', align: 'center'}
                , {field: 'user_status', width: 90, title: '状态', align: 'center',toolbar: '#user_status'}
                , {field: 'user_dj_log', width: '', title: '冻结记录', align: 'center'}
                , {fixed: 'right', width:180, title: '操作', align: 'center', toolbar: '#opeBar'}
            ]]
            ,done: function (res, curr, count) {
                $('.img-circle').viewer({
                    url: 'data-original',
                });
            }
        });
        //批量操作
        var $ = layui.$, active = {
           excelAll: function(){
                //导出Excel
                wk.excelAll('',$('.layui-input').serialize(),"{:url('excelOut')}");
            }
        };
        $('.layuiBtn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        var getIds = function () {
            var ids = [];
            var checkStatus = table.checkStatus('testReload')
                    ,data = checkStatus.data;
            $.each(data,function(index,item){
                ids.push(item['user_id'])
            });
            return ids;
        }
    });
</script>
</body>
</html>